<div id="formbox" >
	<div class="padding">
		<div id="feedback-success">
			<p>Das Ticket wurde erfolgreich erstellt/bearbeitet. <a href="/<?= Zend_Registry::get('Zend_Locale') ?>/tickets/">(zurück zur Übersicht)</a></p>
		</div>
		<div id="feedback-error">
			<p>Beim Erstellen/Bearbeiten des Tickets gab es einen Fehler. Bitte kontaktieren Sie den Administrator. <a href="/<?= Zend_Registry::get('Zend_Locale') ?>/tickets/">(zurück zur Übersicht)</a></p>
		</div>
		<form method="post" id="ticketform" name="ticketform" action="#">	
			<fieldset style="border:1px solid #ccc;">						
				<legend><?php echo $this->translate("Neues Ticket erstellen"); ?></legend>
				<div class="ffield">
					<label for="pid" ><?php echo $this->translate("Projekt"); ?><sup>*</sup></label>
					<select class="input" id="pid" name="pid">
						<!-- Vorerst keine Möglichkeit, Tickets ohne Projekt abzuspeichern -->
						<!-- <option value="0">(ohne Projekt)</option>  -->										
						<?php 
						foreach($this->projects as $project) { ?>
							<option value="<?php print($project['pid']); ?>" <?php if($this->ticket['pid'] == $project['pid']) echo 'selected="selected"'; ?>>
								<?php echo $this->translate($project['ptitle']); ?>
							</option>
						<?php } ?>
					</select>
					<br />
				</div>
				<div class="ffield">
					<label for="ttitle" ><?php echo $this->translate("Titel"); ?><sup>*</sup></label>
					<input class="input" type="text" id="ttitle" name="ttitle" value="<?= $this->ticket['ttitle']; ?>" /> <br />
				</div>
				
				<div class="ffield">
					<label for="description" ><?php echo $this->translate("Beschreibung"); ?><sup>*</sup></label>
					<textarea class="input" id="description" name="description"><?= $this->ticket['description']; ?></textarea><br />
				</div>
				
				<div class="ffield">
					<label for="workerid" ><?php echo $this->translate("zuweisen an:"); ?><sup>*</sup></label>
					<select class="input" id="workerid" name="workerid">								
						<?php 
						foreach($this->worker as $worker) { ?>
							<option value="<?php print($worker['uid']); ?>" <?php if($this->ticket['workerid'] == $worker['uid']) echo 'selected="selected"'; ?>>
								<?php echo $worker['firstname']." ".$worker['lastname']; ?>
							</option>
						<?php } ?>
					</select>
					<br />
				</div>
				
				<div class="ffield">
					<label for="status" ><?php echo $this->translate("Status"); ?><sup>*</sup></label>
					<select class="input" id="status" name="status">
						<option value="Offen" <?php if($this->ticket['status'] == "Offen") echo 'selected="selected"' ?>>Offen</option>												
						<option value="in Arbeit" <?php if($this->ticket['status'] == "in Arbeit") echo 'selected="selected"' ?>>in Arbeit</option>
						<option value="erledigt" <?php if($this->ticket['status'] == "erledigt") echo 'selected="selected"' ?>>erledigt</option>
						<option value="Rückfrage" <?php if($this->ticket['status'] == "Rückfrage") echo 'selected="selected"' ?>>Rückfrage</option>
						<option value="zurückgestellt" <?php if($this->ticket['status'] == "zurückgestellt") echo 'selected="selected"' ?>>zurückgestellt</option>
					</select>
					<br />
				</div>
				
				<div class="ffield">
					<label for="costid" ><?php echo $this->translate("Stundensatz"); ?><sup>*</sup></label>
					<select class="input" id="costid" name="costid">											
						<!-- Preis der Kostenstelle steht aktuell im title-Attribut. Nach AJAX umziehen? -->
						<?php 
						foreach($this->costs as $cost) { ?>
							<option id="costid-<?php print($cost['costid']); ?>" value="<?php print($cost['costid']); ?>" title="<?php print($cost['price']); ?>" <?php if($this->ticket['costid'] == $cost['costid']) print('selected="selected"'); ?>>
								<?php echo $cost['price']."€ "." (".$cost['comment'].")"; ?>
							</option>
						<?php } ?>
					</select>
					<br />
				</div>
				
				<div class="ffield">
					<label for="est_expense" ><?php echo $this->translate("geschätzter Aufwand (in Stunden)"); ?><sup>*</sup></label>
					<input class="input" type="text" id="est_expense" name="est_expense" value="<?= $this->ticket['est_expense']; ?>" <?php if($this->ticket['flatrate'] != "0.00" && $this->edittype != "new") print('readonly="readonly"'); ?> /> 
					<span class="help">Wir haben Ihre Angabe in das richtige Format gebracht :)</span>
					<br />
				</div>
				
				<div class="ffield">
					<label for="flatrate" ><?php echo $this->translate("Pauschalpreis (in Euro)"); ?><sup>*</sup></label>
					<input class="input" type="text" id="flatrate" name="flatrate" value="<?php if($this->ticket['flatrate'] != "0.00") echo $this->ticket['flatrate']; ?>" <?php if($this->ticket['flatrate'] == "0.00" || $this->ticket['flatrate'] == "") print('readonly="readonly"'); ?> /> 
					<span class="tip">(Feld anklicken zum aktivieren)</span>
					<br />
				</div>
				
				<div class="ffield">
					<label for="deadline" ><?php echo $this->translate("Zeitziel"); ?><sup>*</sup></label>
					<input class="input" type="text" id="deadline" name="deadline" value="<?php if($this->ticket['deadline'] != "") print(date("d.m.Y", $this->ticket['deadline'])); ?>" /> <br />
				</div>

				<div class="submitbox" >
					<?php if($this->logged != true) { ?>
					<div class="reset">
						<p><a href="#" onclick="document.ticketform.reset(); return false"><?php echo $this->translate("Löschen"); ?></a></p>
					</div>
					<?php } ?>
					<div class="submit">
						<p><a id="submit-ticketform" href="#"><?php echo $this->translate("Abschicken"); ?></a></p>
					</div>
				</div>
				<input type="hidden" name="edittype" id="edittype" value="<?php echo $this->edittype; ?>" />
				<input type="hidden" name="tid" id="tid" value="<?php echo $this->ticket['tid']; ?>" />
			</fieldset>
			<div style="margin-top: 25px;"></div>  
		</form>
	</div>
</div>